
import random

def points_gen( dimension, size_of_dimension,  num_objects):
	Poset = dict()
	pushed =  []
	node = None
	try:
		#-----
		keys = []
		for x in range(int(dimension)):
			keys.append( str(x)+"_"+str(x) )
		for k in keys:
			Poset[k] = [2] 	
		#-----
		num = 0
		yield num_objects
		while num <  num_objects:
			dat = []
			for j in range(dimension):
				j = int(random.uniform(1,size_of_dimension))
				dat.append(j)
			#print >>sys.stderr,"add",dat
			yield dat
			num += 1
	except:
		raise

def write_points(out,dimension, size_of_dimension,  num_objects):
	import cPickle
	f = file(out,"wb")
	for point in points_gen(dimension, size_of_dimension, num_objects):
		cPickle.dump(point,f,0)
	f.close()	


if __name__ == "__main__":
	import sys	
	out_pkl = sys.argv[1]
	dim = int(sys.argv[2])
	num = int(sys.argv[3])
	size_of_dimension = int(sys.argv[4])
	write_points(out_pkl+"_dim_"+str(dim)+"_num_"+str(num)+"_domain_"+str(size_of_dimension)+".pkl",dim,size_of_dimension,num)
	
